package com.itrip.itripbiz.controller;
import com.itrip.common.ValidationToken;
import com.itrip.service.FlushOrderStatusService;
import org.jboss.logging.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class ScheduledTask {
    private org.jboss.logging.Logger logger = Logger.getLogger(ValidationToken.class);
    @Resource
    private FlushOrderStatusService flushOrderStatusService;

    //每十分钟扫描一次
    @Scheduled(cron = "0 0/10 * * * ?")
    public void flushCancelOrderStatus() {
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("现在的时间是你好："+ sf.format(date));
        try {
            int i = flushOrderStatusService.flushOrderStatusSum();
            if(i == -1){
                new Exception();
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
            System.out.println("联系管理员");
        }
    }
}
